package encode

import (
	"bytes"
	"encoding/binary"
	"time"
)

type RequestMeg struct {
	ReqBody interface{} //请求方法
	ReqId   int         //请求消息类型

}

type ResistBody struct {
	Add        string
	ServerName string
	StartTime  time.Time
	TimeOut    int
}
type CallBody struct {
	Method      string
	Agre        []interface{}
	ContentType string //消息格式
}

type Untily struct {
}

func (u *Untily) IntToBytes(n int) []byte {
	tmp := int32(n)
	bytesbuff := bytes.NewBuffer([]byte{})
	binary.Write(bytesbuff, binary.BigEndian, tmp)
	return bytesbuff.Bytes()
}

//字节转换成整形
func (u *Untily) BytesToInt(b []byte) int {
	bytesBuffer := bytes.NewBuffer(b)
	var tmp int32
	binary.Read(bytesBuffer, binary.BigEndian, &tmp)
	return int(tmp)
}
